// pages/new/new.js
const http=require('../../models/HTTP')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    offset:0,
    playlists:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad:async function (options) {
    var res=await http.getCatData(this.data.offset)
    console.log(res)
    var playlists=res.data.playlists
    console.log(playlists)
    this.setData({
      playlists
    })
  },
  onReachBottom:async function (){
    var offset=this.data.offset  //获取data中的offset
    offset+=35                   //更改offset
    console.log(offset)
    var res=await http.getCatData(offset)  //根据新offset发送请求
    var playlists=res.data.playlists
    console.log(playlists)
    this.setData({
      offset,                              //更改data中offset值再重复
      playlists:this.data.playlists.concat(playlists)   //拼接data中的playlists和新得到的playlists
    })
  }
})